import {Component, OnInit} from '@angular/core';
import {HttpService} from "@core/services/http.service";
import {NzMessageService} from "ng-zorro-antd";

@Component({
    selector: 'app-project',
    templateUrl: './project.component.html'
})

export class ProjectComponent implements OnInit {
    loading = false;
    searchValue = '';
    data = [];
    param: any;
    selectValue = '';
    len;

    ngOnInit() {
        this.getprojectType();
        this.getData();
    }

    s_list = []

    getprojectType() {
        this.loading = true;
        this.http.projectType().subscribe(res => {
            if (res['code'] == '0') {
                this.s_list = res['List'];
            } else {
                this.msgService.error(res['msg']);
            }
        });
        this.loading = false;
    }

    getData() {
        this.param = {
            userId: 82,
            condition: this.searchValue,
            flag: this.selectValue
        }

        this.loading = true;
        this.http.projectList(this.param).subscribe(res => {
            console.log('code:' + res['code'] + "  msg:" + res['msg'])
            if (res['code'] == '0') {
                this.len = res['List'].length
                this.data = res['List'];
            } else {
                this.msgService.error(res['msg']);
            }
        });
        this.loading = false;
    }

    search() {
        this.getData();
    }

    constructor(private http: HttpService,
                private msgService: NzMessageService) {
    }
}
